package com.qfedu.aunt.commons.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qfedu.aunt.commons.pojo.Aunt;
import com.qfedu.aunt.commons.result.R;
import com.qfedu.aunt.commons.service.AuntService;
import com.qfedu.aunt.commons.vo.AuntVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 阿姨表 前端控制器
 * </p>
 *
 * @author xiaobobo
 * @since 2022-10-26
 */
@RestController
@RequestMapping("/aunt/commons/aunt")
@Api(description = "阿姨模块",tags = "阿姨模块")
public class AuntController {


    @Autowired
    private AuntService auntService;

    /**
     * 通过城市名字分分页查询阿姨的信息
      * @param cityName
     * @param currentPage
     * @param pageSize
     * @return
     */
    @ApiOperation(value = "通过城市名字分页查询阿姨信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cityName",value = "城市名字",dataType = "string",paramType = "path",required = true),
            @ApiImplicitParam(name = "currentPage",value = "当前页码",dataType = "int",paramType = "path",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页数据量大小",dataType = "int",paramType = "path",required = true),
            @ApiImplicitParam(name = "token",value = "用户身份标识",dataType = "string",paramType = "header",required = true)
    })
    @GetMapping("findAuntsByCityName/{cityName}/{currentPage}/{pageSize}")
    public R findAuntsByCityNames(@PathVariable("cityName") String cityName, @PathVariable("currentPage")  Integer currentPage,@PathVariable("pageSize") Integer pageSize)throws Exception{
        IPage<Aunt> auntIPage =auntService.findAuntsByCityNames(cityName,currentPage,pageSize);
        return R.ok().setData("auntList",auntIPage.getRecords()).setData("total",auntIPage.getTotal()).setData("currentPage",auntIPage.getCurrent()).setData("pageSize",auntIPage.getSize());

   }


    /**
     * 通过阿姨id查询阿姨的详细信息
      * @param auntId
     * @return
     */
   @ApiOperation("通过阿姨id查询阿姨的详细信息")
   @ApiImplicitParams({
           @ApiImplicitParam(name = "auntId",value = "阿姨id",dataType = "string",paramType = "query",required = true),
           @ApiImplicitParam(name = "token",value = "用户身份标识",dataType = "string",paramType = "header",required = true)
   })
   @GetMapping("/findAuntByAuntId")
   public R findAuntByAuntId(String auntId){
       AuntVo auntVo=auntService.findAuntByAuntId(auntId);
       return R.ok().setData("aunt",auntVo);
   }

}

